<?php //e($javascript->link('jquery/jquery.ajaxtooltip')); ?>
<?php
    $months = array();
    $days = array(
        'en_us' => array('Sun', 'Mon', 'Tue', 'Wed', 'Thu', 'Fri', 'Sat'),
        'zh_cn' => array('星期日', '星期一', '星期二', '星期三', '星期四', '星期五', '星期六')
    );
    $first_of_month = mktime(0, 0, 0, $month, 1, $year);
    $num_days = cal_days_in_month(0, $month, $year);
    $today = date('d');
    $offset = date('w', $first_of_month);
    $rows = 1;
?>
<div class="calendar table">
<table>
    <thead>
        <tr>
            <?php $heads = $days[$session->read('Config.language')];?>
            <?php foreach($heads as $value): ?>
                <th><?php e($value); ?></th>
            <?php endforeach; ?>
        </tr>
    </thead>
    <tbody>
        <tr>
        <!-- Print leading empty cells -->
        <?php for( $i = 1; $i < $offset + 1; ++$i ): ?>
            <td></td>
        <?php endfor; ?>
        <!-- Print cells that has days in it -->
        <?php for( $day = 1; $day <= $num_days; ++$day ): ?>
            <?php if( ($day + $offset - 1) % 7 == 0 && $day != 1 ): ?>
                </tr><tr>
                <?php ++$rows; ?>
            <?php endif; ?>
            <?php $class = ($day == $today) ? 'current' : ''; ?>
            <td class="<?php echo $class; ?>">
                <?php echo $html->link($day, 'javascript:void(0)'/*$day_link.'created:'.$year.'-'.$month.'-'.$day*/,
                    array('title'=> 'ajax:'.$day_link.$year.'-'.$month.'-'.$day)); ?>
            </td>
        <?php endfor; ?>
        <!-- Print ending empty cells -->
        <?php for( $day; ($day + $offset) <= $rows * 7; ++$day ): ?>
            <td></td>
        <?php endfor; ?>
        </tr>
    </tbody>
</table>
</div>